package cloud.mbase.util;

import cloud.mbase.entity.Result;
import org.springframework.http.HttpStatus;

public class ResultUtil {
    private static final String DEFAULT_SUCCESS_MESSAGE = "success";
    private static final String DEFAULT_FAIL_MESSAGE = "fail";
    public static Result getDefaultResult(){
        return new Result();
    }
    public static Result getSuccessResult(){
        return new Result()
                .setStatus(HttpStatus.OK.value())
                .setMessage(DEFAULT_SUCCESS_MESSAGE);
    }
    public static Result getSuccessResult(Object data){
        return new Result()
                .setStatus(HttpStatus.OK.value())
                .setMessage(DEFAULT_SUCCESS_MESSAGE)
                .setData(data);
    }
    public static Result getFailResult(){
        return new Result()
                .setStatus(HttpStatus.BAD_REQUEST.value())
                .setMessage(DEFAULT_FAIL_MESSAGE);
    }
    public static Result getFailResult(String message){
        return new Result()
                .setStatus(HttpStatus.BAD_REQUEST.value())
                .setMessage(message);
    }
}
